﻿using Dnc.Api.Throttle;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Tauren.Business.Entity.Const;
using Tauren.Business.Infrastructure.Common;
using Tauren.Business.Service.DialogService;

namespace Tauren.Business.Core.Controllers
{
    /// <summary>
    /// 弹出框所需接口
    /// </summary>
    [Route("api/dialog"), ApiVersion("1.0")]
    public class DialogController : ControllerBase
    {
        private IDialogServcie service;

        public DialogController(IDialogServcie _service)
        {
            this.service = _service;
        }
        /// <summary>
        /// 获取组织的弹出框树形结构
        /// </summary> 
        /// <returns></returns>
        [HttpPost, Route("v{version:apiVersion}/orgs")]
        [RateValve(Policy = Policy.RequestPath, Limit = 1, Duration = GlobalConst.REQUEST_DURATION_TIME_SECONDS)]
        public IActionResult Orgs() => service.DialogOrg().ToJsonResult(true);

        /// <summary>
        /// 获取职位的弹出框组织的树形结构
        /// </summary> 
        /// <returns></returns>
        [HttpPost, Route("v{version:apiVersion}/postitions")]
        [RateValve(Policy = Policy.RequestPath, Limit = 1, Duration = GlobalConst.REQUEST_DURATION_TIME_SECONDS)]
        public IActionResult Postitions() => service.DialogPosition().ToJsonResult(true);
    }
}
